package com.icloud.wallet.boot.controller.app;

import com.icloud.common.core.api.CommonResult;
import com.icloud.wallet.boot.dto.RechargeOrderDto;
import com.icloud.wallet.boot.dto.WithdrawChargeDto;
import com.icloud.wallet.boot.dto.WithdrawOrderDto;
import com.icloud.wallet.boot.service.ITOrderService;
import com.icloud.wallet.boot.vo.RechargeOrderVO;
import com.icloud.wallet.boot.vo.WithdrawChargeVO;
import com.icloud.wallet.boot.vo.WithdrawOrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@Api(tags = "App订单接口")
@RequestMapping("/app/order")
@RequiredArgsConstructor
public class OrderController {
    private final ITOrderService itOrderService;

    @ApiOperation(value = "充值")
    @PostMapping("/recharge")
    @ResponseBody
    public CommonResult<RechargeOrderVO> orderRecharge(@RequestBody @Valid RechargeOrderDto dto){
        return CommonResult.success(itOrderService.orderRecharge(dto));
    }

    @ApiOperation(value = "提现")
    @PostMapping("/withdraw")
    @ResponseBody
    public CommonResult<WithdrawOrderVO> orderWithdraw(@RequestBody @Valid WithdrawOrderDto dto){
        return CommonResult.success(itOrderService.orderWithdraw(dto));
    }

    @ApiOperation(value = "计算提现手续费")
    @PostMapping("/withdrawCharge")
    @ResponseBody
    public CommonResult<WithdrawChargeVO> withdrawCharge(@RequestBody @Valid WithdrawChargeDto dto){
        return CommonResult.success(itOrderService.withdrawCharge(dto));
    }
}
